package com.cicc.beergamevirtualsimulationsystem.common.enums.userTypeEnum;


import cn.hutool.core.util.EnumUtil;
import com.cicc.beergamevirtualsimulationsystem.common.enums.BaseEnum;
import com.cicc.beergamevirtualsimulationsystem.common.exception.BizException;
import com.cicc.beergamevirtualsimulationsystem.common.exception.ExceptionFactory;
import lombok.Getter;

import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;

/**
 * 角色类型：角色类型枚举
 */
@Getter
public enum RoleType implements BaseEnum {
    CUSTOMER(0, "客户"),
    FACTORY(1, "工厂"),
    SUPPLIER(2,"批发商"),
    RETAILER(3, "零售商"),

    ;
    private final Integer code;
    private final String desc;

    RoleType(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据code获取desc
     * @param code
     * @return
     */
    public static String of(Integer code){
        for (RoleType value : RoleType.values()) {
            if (value.getCode().equals(code)){
                return value.getDesc();
            }
        }
        throw ExceptionFactory.bizException("角色类型不存在");
    }



}

